home *** CD-ROM | disk | FTP | other *** search
- /* SpinCursor.c */
- /*
- * List In A List Sample
- * SpinCursor.c
- * Copyright © 1993-94 Apple Computer Inc.
- * This is based on a sample in Think Reference 2.0.
- */
- #include "ListInAList.h"
- #define ACUR (**gACUR_Handle)
-
- /*
- * SetupAnimatedCursor
- * Build the animated cursor handle array (in global gACUR_Handle)
- */
- void
- SetupAnimatedCursor(
- short acurResID
- )
- {
- short cursorID;
- short i;
-
- gACUR_Handle = (ACUR_Handle) GetResource('acur', acurResID);
- if (gACUR_Handle != NULL) {
- DetachResource((Handle) gACUR_Handle);
- for (i = 0; i < ACUR.nFrames; i++) {
- cursorID = ((unsigned long) ACUR.frame[i]) >> 16;
- ACUR.frame[i] = GetCursor(cursorID);
- if (ACUR.frame[i] == NULL)
- break;
- HNoPurge((Handle) ACUR.frame[i]);
- }
- ACUR.nFrames = i;
- ACUR.nextFrame = 0;
- if (i == 0) {
- DisposeHandle((Handle) gACUR_Handle);
- gACUR_Handle = NULL;
- }
- }
- gACUR_NextAnimation = 0;
- }
-
- /*
- * SpinCursor
- * This is called repeatedly to change the cursor animation.
- */
- void
- SpinCursor(void)
- {
- unsigned long now;
-
- if (gACUR_Handle != NULL) {
- now = TickCount();
- if (now > gACUR_NextAnimation) {
- gACUR_NextAnimation = now + kAnimationInterval;
- if (ACUR.nextFrame >= ACUR.nFrames)
- ACUR.nextFrame = 0;
- SetCursor(*ACUR.frame[ACUR.nextFrame]);
- ++ACUR.nextFrame;
- }
- }
- }
-